ZSTD support - #34
Conversation
f071d68 to
56e62fb
Compare
6d44cca to
2dbdabc
Compare
|
Thank you for updating my PR! I'm not part of the NSIS team though, so I can't really help you get this merged. I see you've updated zstd - I had made a few patches to reduce the size of exehead: https://github.com/dbeinder/nsis/blob/d353438eff9244cc2416e1b7bb0b17551a25941d/Source/zstd/zstd-v1.5.6.diff Not sure if this is still worth doing, or if the NSIS team considers minimal exehead size a priority. |
|
I think its best not to alter the zstd sources for easier maintenance, or changes must be upstreamed first |
|
Well it's a matter of priorities - I think it's safe to say NSIS isn't on the "update dependencies and push a release every week" side of the spectrum ;) |
|
I did not check the minimal size : my use-case is for a large archive that takes forever to compress. |
realloc copied the new size instead of min(old,new); memmove used unsigned int instead of size_t; memset was missing for MSVC /nodefaultlib builds; calloc lacked overflow and NULL checks; memcpy is now word-at-a-time. Also fix nsis_rotl (shift 0 UB), nsis_rotl64 (>=32 rotate), nsis_byteswap_uint64 (halves swapped), nsis_allmul (missing carry and cross terms) and nsis_allshl (rotated low half).
The NSIS_* wrappers were dead code: bundled threading.h called Vista+ imports directly, breaking the XP-compat design. Route the pthread condvar macros through DynamicCondVars and fix its header linkage (proper extern "C" block) and GetProcAddress casts.
AddZstd never ran the configure check on win32 so LIBS was never set; unify both platforms through CheckLibWithHeader, require >= 1.4.0, and define USE_SYSTEM_ZSTD so sources include <zstd.h> instead of mixing bundled headers with a system library. Also detect zstd.dll besides libzstd.dll.
Both branches appended ZSTD_MULTITHREAD; always define it (DynamicCondVars is always compiled) and only add bundled sources when no system zstd is used.
Use cores-1 workers, skip multithreading for single-core machines and inputs under 256KB, and fall back to single-threaded if the library rejects nbWorkers. Clamp levels defensively, support <zstd.h> for system builds, use a thread-local error buffer, and include <unistd.h> directly instead of relying on transitive includes.
Accept 0-19 regardless of the currently selected compressor (restores level 0 and allows SetCompressionLevel before SetCompressor); each compressor clamps to its own range in Init instead of failing the build.
Define ZSTD_MULTITHREAD like makensis, support system zstd via USE_SYSTEM_ZSTD, always compile DynamicCondVars.c (CZstd needs ConditionVarsSupported in both modes), and add an include guard to decompress.h.
The BMI2 asm loop object is not part of the stub build, so gcc/mingw links failed; disable runtime BMI2 dispatch as the unit tests already do. Also document that the session-only reset preserves the magicless format.
Move the zip2exe Solid checkbox so it no longer overlaps the ZLib radio button, and extend all toolbar strips to 15 frames (duplicating the BZIP2 icon as a placeholder until dedicated ZSTD art exists).
|
@sredna I pushed a batch of fixes, would it be possible for you to trigger the CI run ? |
Document zlib 0-9 range with clamping when levels are set before SetCompressor, and drop the stale 34KB stub overhead claim which no longer holds for zstd stubs.
MSVC stub builds compile SCons/Config/memset.c, which clashed with the unconditional memset in crt_replacements.c (LNK2005). Guard both definitions with _NSIS_NODEFLIB_CRTMEMSET/_NSIS_NODEFLIB_CRTMEMCPY, defining the former in SCons/Config/ms and both in SCons/Config/gnu, mirroring the existing mini_memcpy precedent.

refreshed #28 without the math changes, and no asm, as requested
also forwarded the new data size argument to zstd
/cc @dbeinder @sredna